replace logic, somewhat