File improvements and removed duplicated code