please refactor repeating code below - all functions are doing the same