for assignment 4 of CSL374