Simplify and make more extensible