fix bug with ties