safe-divide function

@kiril