Improve light algorithm