good version

replaced with clean code. tested and works.