cleaned up the javascript to be clearer.