refactor task 4, change int to double