better implementation on files and contents