refined sudo code for to meet requirments