working better than first version