cleaned up a lot of code