migrated code from assignment 6