Added efficiency evaluating and refactored.