added the conditional stements

Added the conditional statements for the function