addition of lines to deal with empty strings and resulting division by 0