Better implementation of f.x