Move storePost into separate function