fix discount, javadocs and began optimising code