putting the code in the app delegate