Modified the code for process status checking