Flexible top-down control in the interaction between working memory and perception