finished new splitting
switched to temporary tables due to performance