You could take a look at the async module for doing this. I believe it'd cover it ?