code changes and rework