major refactoring; implemented rotation by brightness