more reworking. untested