Minor refactoring. Added check() command/function.