ENH less nested code