another attempt at fixing the dangling bug