added pre and post conditions