Simplified the js a bit