def METHOD_NAME(email):
    username = normalize_username(email.split("@", 1)[0])
    username_regex = r"^{0}[0-9]*$".format(escape(username))
    users = User.objects.filter(username__iregex=username_regex)
    if users.count() > 0:
        ids = []
        for user in users:
            # get the number at the end
            i = user.username[len(username) :]
            # in case there's no number in the case where just the base is taken
            if i:
                i = int(i)
                bisect.insort(ids, i)
            else:
                ids.insert(0, 0)
        for index, i in enumerate(ids):
            if index + 1 < len(ids):
                suggested_number = i + 1
                # let's check if the number exists. Username can have leading zeroes
                # which translates to an array [0, 1, 1, 2]. Without the membership
                # check this snippet will return 2 which is wrong
                if suggested_number != ids[index + 1] and suggested_number not in ids:
                    break
        username = "{0}{1}".format(username, i + 1)
    return username