red black implementation, debugging needed