Added some conditional statements.