updated logic and css to fix cell misalignment issue