modified to work with plugin