fix bug with directory permission, change logic of pushd function