improve patterns and generators