Generating embedded urls and some error checking