Cleaning up

Placed code into a function, slightly edited messages to be more
understandable