Fixed function not returning True where needed