Added logic in comments