Enhance performance by calling few functions once.