refactor with thenjs