REFACTOR!

Still a bit messy