function to get symbols and a bit of refactoring