Fixing a divide by 0 condition close #312