algorithm working and rendering!