added alghoritm