plugged in reduce() function where needed

math functions (math assignment not needed as they call math functions)