fixed sync_app function