refactoring, better parsing