Change checking code for better structure.