Refactor js example