refactor builder and reduce state across multiple calls
check background of groups to determine transition. resolves #599.