implemented check code. doesn't work, but compiles and runs.