Moved common functions to helper file