refactoring
fixed nullpointerexception