added many things to localization algorithm