Added support for both negative and positive offset in period condition