updated code to use the overloaded < operator