refactored light code.