fixing compilation errors
Implementing part of ranking