Removed unused codes and improved variable names