corrects whitespace and small bug with total function