refactor plugin to conform to jquery plugin documentation