Uses a few utility functions so there's much less code.