final changes, added wait queue