Making code more concise, adding comments and function compatible with S+ base