Fix nullPointerException in sample