refactored posting function and controllers