complete code for all versions