DDBNEXT-977: Refactoring of javascript