Stripping logic out into another function