Adding ANSI color output. Refactoring code