modified fs function