Simplify this code