Implemented xoft suggestion (partly)

I only get it working in first condition. It seems it's not compatible with else if...