fixed bug #26 and started implementing enhancement #38