working on parsing algorithm