updated: better helper functions using native javascript methods instead of jQuery