refactory into utilities and base classes