restructured to handle bigger files