Updated to work fully