code review changes in JS
code review changes: simplifying PHP code