Added error handling to plugin