Refactor with better error handling, golang camelcase