add error handling and remove reflection