clean up.  move trigger function to java.