Passing javascript functions as arguments