fixing code to allow for smaller boxes than what the target structure was