re-factor to use webworkers