code modified for applying theme