refactor so that calculations can be used without connection