Tested and refined code to it's simplest form.

Tested and refined code to it's simplest form.