added a mutex for printing