removed unused variables and code formatted