algorithm changes, hopefully it works