Made the program a bit more intelligent.