Refactoring into functions. Basic handling of '-' and '.'