more efforts; works better for non-readline now