modified for 256-colors support