Replace function by class