Re-ordered code and introduced long as data type for the product calculation to prevent overflows.
Added TODO.