fixed -1 bug