Final code and results