updated parse algorithm