refactored to change implicit real*8 to implicit none