Design an algorithm in Python to find the number of occurrences of a given string in another string.
haystack = "Hello World"
needle = "l"
def count_occurrences(haystack, needle):
    count = 0
    for char in haystack:
        if char == needle:
            count += 1
    return count