added proper space handling