1st assignemnt complete, algorithm is a little weird, will change later