Use partial function for error handling