fix bug with before at index 0