Made nicer solution to Ass3.3 code, and added pre/post conditions.