Added guard on toString method to avoid Null Pointer Exception.