refactor function, object, ctx