Moved common functions to the utils
Some refactoring