re-working the code to be multi-threaded with ability to record