completely refactored the stdout method out in order to be able to use it somewhere else.