add POST functionality & broke code up to make portable and legibile