changed the width logic to old logic with a fixed bug in the code