cleaned up some of he code