added volatile keyword to make the double-check locking safe