Added error check in after/plugin