Fix bug in initial and rest method
Dont use array.filter for performance issue