improve the parse function