rework some things to fix edge cases