Add better handling for nil in post function.