removed code duplication for filesystem operation