Added mutex locking to the controller class