I'd split this logic out into more specific methods.