refactored in to 2 flows