Added function docstring, some comments, and changed prints to returns.