Moved puts statements to outside of the function.