Refacto to clean up nested callbacks