Rewriting some code. It hurts