Fixed so the function returns a value to a if statement