rework some code