Passes all tests and actually works.