merged version with jquery