Refactor parsing
Fix query