all kinds of ugly codes I wrote