cleanup

a bit code cleanup and adding InvalidInputError to indicate wrong files