changed the if clause to respondsToSelector