Added a function to DRY code + Vars and functions names refactoring