made some syntax fixes and added json output