improved: using table for result