Adding missing import, catching all possible outcomes in function.