finish refactoring
working in FF & Chrome now.