Issue 417

Simple fix for this issue. Reduced some duplicate code at the same time.
Don't add extra spaces