fix weird logical behaviour

Just for cleanup the logic part and get it less cluttered.

@Deepdiver @kondou-ger @karlitschek @ringmaster