fixed bugs and added sample statistics