added potential potential division-by-zero cases