fixed slice out of range bug