added nested conditional and loops