updated with correct gap filling function