rewrite the parsing logic