aaagh. fix fill-elements function.