shuftied about the code to be in less dumb places