added a check variables function
improved the check variables function