refactor with correct message displayed as output