added mutex protection around append function