minor refactoring of 4ee93c9f8529cfeef56d4178b91e1ddcb0bff09c

Minor refactoring of 4ee93c9f8529cfeef56d4178b91e1ddcb0bff09c.
/to @mdo for review.