added if statement to post controller