Made script flexible for arbitrary base urls