Move the getJSON callback in a separate function