fix bug in placement algorithm