Merry go round logic added.
Moved logic to separate file.
Changed response format to json.