change function return type from void to bool
have a consistent condition check for reading and writing register function
use class initializer list