Refactor nextSong function