This reads as if it's referring to a variable outside it's scope (rim_width). Did you mean halo_dim?