fixed bugs. added predict function.