* Fixed incorrect directory reference
* Abstracted some of the code