Total rewrite. Now it can handle whitespaces.