basic algo working