Refactored code showing approaching, leaving and stationary buses