Bug fix in state machine, now only works if a grayscale layer is used