Apply function, otherwise return value