done issue #14; some code improvements