protect against divide by 0 when input buffer is empty
remove unused variable in tap