Implemented rule one and rule two. Still need to do testing and modify the output function