extract value error checking and generation to a method
extract url error checking and generation to a method