check for defined methods before null checking to avoid nomethoderror