update: utilize dirname()

makes code less OS dependent and cleaner