locking refactor sketch (won't compile)