fix
refactoring
implemented listening for signal sigterm