This block seems very similar to the one above.  Can you refactor this to remove the duplication?