added mutex functionality