parsing function splitted to several steps