Fixed None value error handling