example code for javascript (may be java)