Pure JS Helper functions