Cleaned up code and removed unnecessary vars