[Refactoring] Move common functions to helper.js