switched to jquery and fixed a bug