Part of fourth homework assignment for CIS191