fixing types and code