man a lot of this code embarrasses me