optimized db insertion and solved size problem