rewrite convertation to JSON