refactored with output class, added more features; convert all to lowercase