logic changes, needs review