Your debounce delay is too short... swap PAUSEUS for a straight PAUSE. 200mS is neither here nor there in the great scheme of a train moving past your reed switch, whereas in 200uS which you have currently, the train would barely have moved a fraction of a millimetre... With some experimentation, you might find that PAUSE 50 will do...