js early binding refactor