Updated code to shorten it