Make code in app delegate more clear