Edited to remove dependence on a plugin