split val and valf functions