refactor smartform.js