Updated to use buffer and fs