Added logic for levels.