Refactor: move sm related functions to check-sm.sh