This whole block is mostly duplication of the one at line 83?