Some error handling for edge cases