- Changed threaded code to use switch based