code simplification with functional operations