try break instead of return 0; optimize the tests
rm unnecessary else condition that caused the function to terminate prematurely
Don't change directory nor list directory contents if new_dir is the PWD