Nodejs code improved