Refactor. Added support for header variables