Use SplQueue instead of an array