added more checks and ability to get from a url