refactors method that parses names