code rearrangement and client code factory