improve fly function