extracted code into methods