Added default values and error handling