looks like this bit of logic could get pulled into a helper function do be more DRY