fixed a domain bug and factored the code in base class