moved buffer to local definition