minor cleanup, moved code to sub for readability
fixed typo in documentation
initial version