implementation of issue # 209. Also implemented it for continuous