Added margin checking (longer than longest dictionary word) and performing margin reduction (to find min cost) based on longest word)