added several new classes and logic