Implemented efficient algo ann