Version 1.7 Tweaked code for better testing