Refacturing code

rename variables, adding missing brackets, remove/add white spaces.