Still need to refactor this to be thread safe