working version for parsing