Removing irrelevant parts and added loop to remove trailing - characters from the string without effecting a potential negative value.