not sure if this solves a potential race condition