second solution : using double