refactored code into crude interface