Removed unused codes and improved variables