updated keyprocessing, including critical section