new code to include better error checking and posting