Fixed an issue with the level calculation