code review changes: used array_unique() instead of !in_array() twice
code review changes: force using index while quering for recent changes