replaced old bad javascript with better one