update theme algorithm