handle zero case, add documentation