added logic for determin the need of reboot