add logging and checks