implementation of loops and conditionals