refactoring to make code more clear(renaming variables, split large subroutines to small parts)