Can these be consolated into a single function that takes an argument which is passed into sub?