part2: fixed null pointer error