Changed right and left overflow logic to work correctly