fix bug in x() function