more testing and added some clean code