moved some logic into clases