move reading of paths and names to its own function