Finished coding and testing the dynamic version