Fix parsing logic