javascript improvement