polished up some code