added if else statement and called function