Are you supposed to check pos != npos here ?