Utility functions for Javascript