Updated with more efficient JS.