Removed some unneeded code and renamed variables