Passes Mr. Oblig but needs some refactoring
Adds filetype check and small refactoring