fix condition for y bound check