using latest ag-js, some polishing