Updated to use the comppand, and directory check