working version but slow for individual flight curves