Prevent calling getData on a non object error