simplify logic
fix testing