fixing queue not dereferences before use