formula function adapted