Added constant for FOREVER=-1. Simplified code