Add guard for block initialization and use of attr_accessor instead of instance variables