renamed some variables, extracted a method
moved function declaration
renamed variables