Fixed syntax error
Simplified g method