refactor code, "play_idle_loop" function