Passes tests and simplifies code