refactor and delete old file