made json output pretty, better print function selection