try to improve buf calc