Common function refactor