take out handle json  part in to other file with protocols together maybe