call a method on an object only if it exists