implement javascript callback functionality