Replaced the first function with the new better function