You are doing a pretty weird thing here... use async. You are performing a two element series by passing the second element as a callback. Using different functions at the same level you will have a much more modular and reusable code.