moved to instance methods and refactor to classes