Inserted some error checking and made the check respond properly if someone mistypes the url / give an url that doesn't exist (e.g. 404).