Refactoring and improved auto check