Refactored code into functions for reuse.

COMPUTER SCIEEEEENCE!