added popular api call, restructured code