Redesigned code
Resolved issue #8