added terminal condition, changed location weights