Added function with nested conditionals.