Refactor to support Javascript custom rules
Refactorign for javascript support