performance enhancements

improved logic, substitution of vanilla js instead of jquery