fix null pointer. added output