refactor of buddy-pair-prog-code and added some minor error handling