updated to use dirname so it can run from anywhere