added locking to logfile