js utility functions