added javadocs and more validation