refactor + printed some info on stderr