fix bug with CE button
start of refactoring