add error handling and also make it more convenient