Following function and code refactoring