refactor with partials
add error handling