Simplify some of the code