Cleaning up and organizing check code into function blocks