refactors for JSON objects rather than var for everything