organized code, better algorithm of obtaining playlist