Factorized a function out for debugging purposes