Fix null master problem
Add error code