add variable checking, use sam rewrite sed logic