Simplify code logic