Fixed find_aligned function