use prev == -1 to check remove element