All functions rewritten to native javascript