CHanged logic to accomodate light sensor