Converted modal script into a plugin