added writing module
basic threading implemented, modularized functions