eliminated unneccessary variables, cleaned up some code