it works! code not the prettiest, though
it returns json! code still ugly