fix #29: inserting code and libs from HW5. introduced issue #30.