trying to fix algo