doing some javascript magic, feeling pretty good about myself