fix Shem's bugs