use method instead of duplicating code