new functions for #506
fix #506 on JS