made somerequested fixes
cleaned up code