using loops instead of hardcoded rules