Fix segmentation fault
Refactoring
Refactoring
Refactoring