gsm library  refactoring