Move conditional to prevent calling trim() on void when no name provided