rewrite to use scope