JavaScript helper functions