refactoring to stages
implemented