moving most java functions (few) to javascript side