a bit better array management. NEED TO FIX JS