Adds some error checking to shortcode function.