cleaned up some wierd looking code