Locking for thread safty
Clear formatting