name fix, better error handling, using function from files