simplified and fixed find_slot