Refactor and fix derp