Moved writing of makeflow to seperate function