Use while loops for consistency and also get rid of Array::filter