debugged code so that red and blue cells show properly