working on flying algorithm