added a previous mode parameter to allow fading out