start to cleanup. refactored to jQuery plugin style