Reduce code and fix console message sending