added another solution as version2