added comment, fixed cd, and added wait to pipe. but there is a problem with the cd after you pipe