Final code for submission