moved some things from run() into the constructor