adding max flight time
making code more generic