fix bug with x being undefind