use inheritance instead of function