refactored code out of here into spitfire library and called from here