Modify to use double instead of float