added error checking for post parameters