removed sum portion of function
fixed if