refactoring error; fix null ref in shape handling