changed to allow for threading