didn't quite do this for logging purposes, but simplified it and made it dry-er