fix pointer bugs