Fixed empty data issue and added json output