Changed code to support better modifiability