parse logic