Added conditionals to functions