Adding variable check, simplifying dir rm