logic adjustments (refactoring is needed)