Updated to work as a plugin