Fixed +-1 bug