fixes potential division-by-zero error