enhanced simplifySum's factor-out entry point