fix expr parsing algorithm