playlist code refactored