refactored lab12