moved logic to app delegate