Fix the javascript that changes states