clean code, reduce nested code