Refactoring varnam handlers functions to reuse same code