fix bug in popular sorting