pass through useragent; error checking; split into different files