Created the get maximum wight function