removed not used variables. Renamed variables to reflect their fucntion, code refactoring