Changed logic for saving functions in post controller