threading and locking still a teenie bit buggy but everything works