started refactoring code