moved buffer up into mapped func