change to use delegate and cleaned up based on style guide