Removed unused codes and improved codes