removed unused code, added Jay's code