added space triming for strings and improved the behead logs