Ugly, but passing tests! :)