Added url validation
More validation and error-checking.