move requests inside function; clean up PW check