code clean up: removed redundant variables and renamed some variables