cleaned up code by adding primarywhere method to the flow manager