fixed divide by zero error and when wrong total with multiple keys