added improved code, with better tests