initial parsing logic