replaced Exception with BadFunctionCallException on reduce() method