Javascript code refactored