optimize code: no need to over POST parameters twice