completely change algorithm. doesn't works