Refactor based on @jroper comment.