normalize and simplify code