updated code to replace spaces with regular spaces