added some conditional statements