Add conditionals for avoiding division