sgos rewrite