more logic and tests