move smex to separate file