used local booleans to make compact code