moved errorcheck to _get_elements function. removed from main function.