String parser refactored