migrated to classes

but still not working yet for multiple threads