Simplified code and removed unneeded code