Fix dan's null pointer exception