refactored and heavily commented josh pathhandler