started refactoring and modifieng it