improve url validation and error messaging