added if statement

added if statement for function