fixed slice out of bounds error