adding logging, error handling