The problem is not B3 and the beep routine though, the endless loop goes between the start and delay routines (controlled by B4).