added authorization and conditionals