cleaned up some bugs in AI code
relates #65
added guard clause in ai
relates #65