I am checking first for the ending condition and then for bouncing conditions