refactored code because Cascades January release fixed some bugs

Signed-off-by: ekkes-corner <ekke@ekkes-corner.org>