started refactoring into methods