Add last() function
Add condition statement