adjusted the procedure for theming