add chrome, opera, IE compatibility, optimize algorithm