loops executed properly, some bifs added