with guard against negative numbers