Made post function more modular