Fix division by zero

An if statement was added to deal with the case where the table is empty.

Change-Id: I7e370034e26b8b5d0eb940712eec149be0b332bb
Merge "Fix division by zero"