Extracted more code into methods