Refactoring to use JavaScript only
Merging changes with Rachel's updates