second assignment - completion (added NPE checks)