added some logic to setting light level