adding a check for wp_error