replace == by HasPrefix for names and improve error message