improved version with post request