javascript: removed redundant anonymous function