Added Null Reference Error handling.