Optimized playMusic by getting rid of needless for loop