re-edited Tarun's code, he needs to find more references.