cleanup code for version 4