Simplify and abstract a bit.