refactor and fix fileformat