added sendMessage method, also some jsonRefactor