changed code in appDelegate