fixed bug that pauses after loop