generate method potentially bug-free