updating for valid urls
removing duplicate code