UPDATED JAVASCRIPT