fixed #146 improved code