several js fixes in order to make logic work on wp