refactor implementation, better parsing logic