changes to better related algorithm