Made returnJSON($returnStatement) happen only in finish(). This is a much better place for it to happen.