code re-write, setting brightness added