[update:] code refactoring
[update:] start to work on handling errors