code reworked into classes