trying for monitor solution to having mutual exclusion