added better path handling functionality

added better path handling functionality that should be more
resilient to user error