fixed if-else condition in extract()