Worked on getResult() algorithm