resolves issue #1

cleaned up the code quite a bit