refactoring code JS + update TODO