made analysis subroutine and started generation code