fixed function that was returning double