Queue functional but with some bugs