Cleaned up some bad code re-user
made some changes, not sure if they are going to work out