IDEA algorithm implemented
Fixed some minor bugs