optimization according to github comments