Hopefully fixed bug when mistake since first char

Some refactoring