throwing in some safeguards and locks