your 'if' statement only checks once
so if elapsed is not > 5000 on the first check
then it just stops