Merge tim code of version 3