Remove redundant code and use only one JSNI method