changing register to return a JSON object