Extracted out a little code.