completely rewritten feature extraction and comparison