added logic, redesign parser