a better parser algorithm