added classes, a little refactoring