have logic working in view, need to refator