fixing the ga function