added return json in every method and removed echo