improved starred/unstarred function, code refactoring using a mode
session var ('default', 'starred', 'history')