Rearranged funtions

Rearranged functions, breaked onJSONLoaded function into two parts.