Removed unused codes and added code improvements