New toJSON method

fixing access to properties