Complete Code (I hope)